package com.dragon.blog.bean.swaggerConfig.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @INFO:
 * @AUTHOR NAIZUI
 * @CLASSNAME ISwaggerConfig.java
 * @CREATETIME 2021-09-23 20:00
 */
@EnableSwagger2
@Configuration
@EnableSwaggerBootstrapUI
public class ISwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dragon.blog.cms.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("接口文档 RESTful APIs")
                .description("描述所有后端代码接口的文档")
                .termsOfServiceUrl("http://localhost:12000/doc.html")
                .contact("18140109033@163.com")
                .version("1.0.1")
                .build();
    }
}
